--- title: "L1-030 一帮一" created: 2025-11-28 tags: - 算法 --- # L1-030 一帮一 ## 题目 [L1-030 一帮一](https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=994805103557459968&page=0) ![[image-9a1d38ad.png]] ## 思路分析 ## 代码实现 ```cpp #include using namespace std; #define endl '\n' #define int long long using ll = long long; using ull= unsigned long long; using PII = pair; using Pll = pair; int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1}; const int inf = 0x3f3f3f3f; const int N = 55; using PIS = pair; PIS student[N]; bool is_match[N]; //const int N=55; //vector male; //vector female; signed main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int n;cin>>n; for(int i=0;i>sex>>name; student[i].first=sex,student[i].second=name; } // for(int i=0;i=0 && student[i].first != student[i].first) j--; // if(student[i].first != student[i].first){ // // } // } //考虑换个思路 因为一定是男女匹配 且保证男女比例为1:1 那么就一定每人都能匹配到 //干脆 男女分别排序 然后一一成对输出 //也不对 这样的话控制不了名次从高到底排列 // int n;cin>>n; // while(n--){ // int sex;string name;cin>>sex>>name; // if(sex==0) female.push_back(name); // else male.push_back(name); // } // // reverse(male.begin(),male.end()); // // for(int i=0;i=0;j--){ if(!is_match[i] && !is_match[j]){ if(student[i].first != student[j].first){ cout<